<?php

namespace App\Entities\Base;

use Doctrine\ORM\Mapping as ORM;

/**
 * App\Entities\Base\VulnerabilityReferenceCode
 *
 * @ORM\MappedSuperclass
 * @ORM\Table(name="`vulnerability_reference_codes`", indexes={@ORM\Index(name="vulnerability_reference_codes_vulnerability_fk_idx", columns={"`vulnerability_id`"})})
 */
class VulnerabilityReferenceCode extends AbstractEntity
{
    /** Table name constant */
    const TABLE_NAME = 'vulnerability_reference_codes';

    /** Column name constants */
    const REFERENCE_TYPE   = 'reference_type';
    const VALUE            = 'value';
    const VULNERABILITY_ID = 'vulnerability_id';
    const VULNERABILITY    = 'vulnerability';

    /**
     * @ORM\Id
     * @ORM\Column(name="`id`", type="integer", options={"unsigned":true})
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(name="`reference_type`", type="string", length=50)
     */
    protected $reference_type;

    /**
     * @ORM\Column(name="`value`", type="text")
     */
    protected $value;

    /**
     * @ORM\Column(name="`vulnerability_id`", type="integer", options={"unsigned":true})
     */
    protected $vulnerability_id;

    /**
     * @ORM\Column(name="`created_at`", type="datetime")
     */
    protected $created_at;

    /**
     * @ORM\Column(name="`updated_at`", type="datetime")
     */
    protected $updated_at;

    /**
     * @ORM\ManyToOne(targetEntity="Vulnerability", inversedBy="vulnerabilityReferenceCodes", cascade={"persist"})
     * @ORM\JoinColumn(name="`vulnerability_id`", referencedColumnName="`id`", nullable=false, onDelete="CASCADE")
     */
    protected $vulnerability;

    public function __construct()
    {
    }

    /**
     * Set the value of id.
     *
     * @param integer $id
     * @return \App\Entities\Base\VulnerabilityReferenceCode
     */
    public function setId($id)
    {
        $this->id = $id;

        return $this;
    }

    /**
     * Get the value of id.
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set the value of reference_type.
     *
     * @param string $reference_type
     * @return \App\Entities\Base\VulnerabilityReferenceCode
     */
    public function setReferenceType($reference_type)
    {
        $this->reference_type = $reference_type;

        return $this;
    }

    /**
     * Get the value of reference_type.
     *
     * @return string
     */
    public function getReferenceType()
    {
        return $this->reference_type;
    }

    /**
     * Set the value of value.
     *
     * @param string $value
     * @return \App\Entities\Base\VulnerabilityReferenceCode
     */
    public function setValue($value)
    {
        $this->value = $value;

        return $this;
    }

    /**
     * Get the value of value.
     *
     * @return string
     */
    public function getValue()
    {
        return $this->value;
    }

    /**
     * Set the value of vulnerability_id.
     *
     * @param integer $vulnerability_id
     * @return \App\Entities\Base\VulnerabilityReferenceCode
     */
    public function setVulnerabilityId($vulnerability_id)
    {
        $this->vulnerability_id = $vulnerability_id;

        return $this;
    }

    /**
     * Get the value of vulnerability_id.
     *
     * @return integer
     */
    public function getVulnerabilityId()
    {
        return $this->vulnerability_id;
    }

    /**
     * Set the value of created_at.
     *
     * @param \DateTime $created_at
     * @return \App\Entities\Base\VulnerabilityReferenceCode
     */
    public function setCreatedAt($created_at)
    {
        $this->created_at = $created_at;

        return $this;
    }

    /**
     * Get the value of created_at.
     *
     * @return \DateTime
     */
    public function getCreatedAt()
    {
        return $this->created_at;
    }

    /**
     * Set the value of updated_at.
     *
     * @param \DateTime $updated_at
     * @return \App\Entities\Base\VulnerabilityReferenceCode
     */
    public function setUpdatedAt($updated_at)
    {
        $this->updated_at = $updated_at;

        return $this;
    }

    /**
     * Get the value of updated_at.
     *
     * @return \DateTime
     */
    public function getUpdatedAt()
    {
        return $this->updated_at;
    }

    /**
     * Set Vulnerability entity (many to one).
     *
     * @param \App\Entities\Base\Vulnerability $vulnerability
     * @return \App\Entities\Base\VulnerabilityReferenceCode
     */
    public function setVulnerability(Vulnerability $vulnerability = null)
    {
        $this->vulnerability = $vulnerability;

        return $this;
    }

    /**
     * Get Vulnerability entity (many to one).
     *
     * @return \App\Entities\Base\Vulnerability
     */
    public function getVulnerability()
    {
        return $this->vulnerability;
    }

    /**
     * Get the display name for the entity
     *
     * @param bool $plural
     * @return string
     */
    public function getDisplayName(bool $plural = false): string
    {
        return $plural === false ? 'Reference Code' : 'Reference Codes';
    }

    public function __sleep()
    {
        return array('id', 'reference_type', 'value', 'vulnerability_id', 'created_at', 'updated_at');
    }
}